package com.liuzu.esys.controller;

import com.liuzu.esys.common.LayuiPageVo;
import com.liuzu.esys.common.R;
import com.liuzu.esys.pojo.Aftersale;
import com.liuzu.esys.service.AftersaleService;
import com.liuzu.esys.vo.YyhPieVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Description :天干物燥，小心火烛
 * @Author : yyh
 * @Date : 2022/07/25 15:08:27
 * @desc
 */
@RestController
@RequestMapping("/aftersale")
public class AftersaleController {
    @Autowired
    private AftersaleService aftersaleService;
    //分页和模糊查询的接口
    //     *  params 接受 分页参数  和  模糊查询参数
    @RequestMapping("/aftersaleList")
    public LayuiPageVo<Aftersale> aftersalePageData(@RequestParam Map<String, Object> params) {
        return aftersaleService.aftersalePageData(params);
    }
    //getMapping会匹配预检请求
    @GetMapping("/deleteAftersale")
    public R deleteAftersale(Integer id) {
        int result = aftersaleService.deleteAftersale(id);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }
    @RequestMapping("/updateAftersale")
    public R updateAftersale(Aftersale aftersale) {
        int result = aftersaleService.updateAftersale(aftersale);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }
    @GetMapping("/addAftersale")
    public R addAftersale(Aftersale aftersale) {
        //添加
        int result = aftersaleService.addAftersale(aftersale);
        if (result == 1) {
            return R.ok();
        } else {
            return R.error();
        }
    }
        //退款状态信息图
    @RequestMapping("/echartsPie")
    public R echartsPie(){

        List<YyhPieVo> list = aftersaleService.statePieData();

        return R.ok().data("statePie",list);
    }

}

